package com.cloudkinto.service.consumer;

import com.alibaba.fastjson.JSONObject;
import com.cloudkinto.common.RabbitQueueConstant;
import com.cloudkinto.service.consumer.vo.orderSyncRecord.PlatformOrderSyncRecordReq;
import com.cloudkinto.service.platform.sync.PlatformOrderSyncRecordService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class PlatformOrderSyncRecordConsumer {

    private final PlatformOrderSyncRecordService PlatformOrderSyncRecordService;

    /**
     * 同步订单表
     *
     * @param msg
     */
    @RabbitListener(queuesToDeclare = @Queue(RabbitQueueConstant.PlatformOrder_SyncRecord_Update))
    public void updateRecord(String msg) {
        PlatformOrderSyncRecordReq req = JSONObject.parseObject(msg, PlatformOrderSyncRecordReq.class);
        try {
            PlatformOrderSyncRecordService.updateSyncRecord(req);
        }catch (Exception e) {
            e.printStackTrace();
        }
    }




}
